package core

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"goblog/initialize"
	"net/http"
	"time"
)

//程序启动 监听端口，路由操作，框架初始化等

func EunServer(){
	//1.初始化理由
	router := initialize.Routers()
	//router := gin.Default()
	//测试
	router.GET("/admin", func(context *gin.Context) {
		context.JSON(200,gin.H{
			"msg":"hello world",
		})
	})
	//2.设置路由地址
	//router.Static()
	s := &http.Server{
		Addr:              "127.0.0.1:8888",
		Handler:           router,
		ReadTimeout:       10 * time.Second,
		ReadHeaderTimeout: 10 * time.Second,
		WriteTimeout:      10 * time.Second,
		MaxHeaderBytes:    1 << 20,
	}
	////保证传输
	time.Sleep(10 * time.Microsecond) //时间为微妙
	//global.GLOBAL_LOGGER.Debug("server start success",s.Addr)
	gin.SetMode(gin.DebugMode)
	fmt.Println("打开成功")
	//router.Run("0.0.0.0:8889")
	s.ListenAndServe()
}